﻿using LibraryManagement.Custom_Controls;
using LibraryManagement.Help;
using LibraryManagement.Inventory;
using LibraryManagement.Membership;
using LibraryManagement.Profile_Management.Setup;
using LibraryManagement.Search;
using LibraryManagement.Security;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryManagement
{
    public partial class ParentForm : libForm
    {
        private LibManagementEntities context;
        private LoginForm loginForm;
        private MasterBranch frmMasterBranch;
        public ParentForm()
        {
            InitializeComponent();
        }

        public ParentForm(LoginForm loginForm)
        {
            InitializeComponent();
            this.loginForm = loginForm;
        }

        private void ParentForm_Load(object sender, EventArgs e)
        {

        }

        private void addBooksToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InvBookAdd frmInvBookAdd = new InvBookAdd();
            frmInvBookAdd.MdiParent = this;
            frmInvBookAdd.Show();
        }

        private void addMemberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MemberAdd frmMemberAdd = new MemberAdd(MemberAdd.Redirection.Add);
            frmMemberAdd.MdiParent = this;
            frmMemberAdd.Show();
        }

        private void branchManagementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmMasterBranch = new MasterBranch();
            frmMasterBranch.MdiParent = this;
            frmMasterBranch.Show();
        }

        private void editMemberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Membership.MemberUpdation frmMemberUpdation = new Membership.MemberUpdation();
            frmMemberUpdation.MdiParent = this;
            frmMemberUpdation.Show();
        }

        private void testingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Testing frmTesting = new Testing();
            frmTesting.MdiParent = this;
            frmTesting.Show();
        }

        private void editBooksToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InvBookUpdation frmInvBookUpdation = new InvBookUpdation();
            frmInvBookUpdation.MdiParent = this;
            frmInvBookUpdation.Show();
        }

        private void uploadDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            context = new LibManagementEntities();
            clsMethods.CreateXML(context.vwBooks.ToList());
            //clsMethods.UploadToFtp(Application.StartupPath + "\\XML Data\\BookDetails.xml","BookDetails.xml");
            clsMethods.UploadToFtpUsingFtpClient(Application.StartupPath + "\\XML Data\\BookDetails.xml", "BookDetails.xml");
        }

        private void issueBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSelectMembers OFrmSelectMembers = new frmSelectMembers(frmSelectMembers.eAction.Issue);
            OFrmSelectMembers.MdiParent = this;
            OFrmSelectMembers.Show();
        }

        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void manageSessionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MasterSession frmMasterSession = new MasterSession();
            frmMasterSession.MdiParent = this;
            frmMasterSession.Show();
        }

        private void setCurrentActiveSessionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SessionSet frmSessionSet = new SessionSet();
            frmSessionSet.MdiParent = this;
            frmSessionSet.Show();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MasterCategory frmMasterCategory = new MasterCategory();
            frmMasterCategory.MdiParent = this;
            frmMasterCategory.Show();
        }

        private void submitBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSelectMembers OFrmSelectMembers = new frmSelectMembers(frmSelectMembers.eAction.Submit);
            OFrmSelectMembers.MdiParent = this;
            OFrmSelectMembers.Show();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            MasterLocation frmMasterLocation = new MasterLocation();
            frmMasterLocation.MdiParent = this;
            frmMasterLocation.Show();
        }

        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ChangePassword frmChangePassword = new ChangePassword();
            frmChangePassword.MdiParent = this;
            frmChangePassword.Show();
        }

        private void userProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewAccount frmNewAccount = new NewAccount(NewAccount.Redirection.Edit);
            frmNewAccount.MdiParent = this;
            frmNewAccount.Show();
        }

        private void ParentForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            loginForm.Close();
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            Feedback frmFeedback = new Feedback();
            frmFeedback.MdiParent = this;
            frmFeedback.Show();
        }

        private void searchMemberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SrcMemberSearch OSrcMemberSearch = new SrcMemberSearch();
            OSrcMemberSearch.MdiParent = this;
            OSrcMemberSearch.Show();
        }

        private void libButton1_Click(object sender, EventArgs e)
        {
            FormCollection fc = Application.OpenForms;
        }

        private void addCopiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SrcBookSearch OSrcBookSearch = new SrcBookSearch(SrcBookSearch.Redirection.CopiesAdd, this);
            OSrcBookSearch.MdiParent = this;
            OSrcBookSearch.Show();
        }

        private void searchBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SrcBookSearch OSrcBookSearch = new SrcBookSearch(SrcBookSearch.Redirection.Search, this);
            OSrcBookSearch.MdiParent = this;
            OSrcBookSearch.Show();
        }

        private void bookSummaryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SrcBookSearch OSrcBookSearch = new SrcBookSearch(SrcBookSearch.Redirection.Summary, this);
            OSrcBookSearch.MdiParent = this;
            OSrcBookSearch.Show();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutBox OAboutBox = new AboutBox();
            OAboutBox.MdiParent = this;
            OAboutBox.Show();
        }

        private void pINCodesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSelectMembers OfrmSelectMembers = new frmSelectMembers(frmSelectMembers.eAction.PinCodes);
            OfrmSelectMembers.MdiParent = this;
            OfrmSelectMembers.Show();
        }
    }
}
